package com.idealighter.game.group.convert;

import com.idealighter.game.core.convert.DateLongConvert;
import com.idealighter.game.group.dto.ApplyInfoDto;
import com.idealighter.game.group.dto.GroupInfoDto;
import com.idealighter.game.group.dto.MemberInfoDto;
import com.idealighter.game.server.db.datadb.generate.domain.RoomCardGroupDomain;
import com.idealighter.game.server.db.datadb.generate.domain.RoomCardGroupMemberApplyDomain;
import com.idealighter.game.server.db.datadb.generate.domain.RoomCardGroupMemberDomain;

import java.util.List;

import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueMappingStrategy;
import org.mapstruct.factory.Mappers;

@Mapper(uses = DateLongConvert.class)
public interface GroupConvert {

  GroupConvert INSTANCE = Mappers.getMapper(GroupConvert.class);

  @Mapping(target = "groupId", source = "domain.id")
  @Mapping(target = "memberAvatars", ignore = true)
  GroupInfoDto toGroupInfoDto(RoomCardGroupDomain domain);

  @Mapping(target = "applyId", source = "id")
  ApplyInfoDto toApplyInfoDto(RoomCardGroupMemberApplyDomain domain);

  @IterableMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
  List<ApplyInfoDto> toApplyInfoDtos(List<RoomCardGroupMemberApplyDomain> domains);

  @Mapping(target = "memberId", source = "id")
  MemberInfoDto toMemberInfoDto(RoomCardGroupMemberDomain pojo);

  @IterableMapping(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
  List<MemberInfoDto> toMemberInfoDtos(List<RoomCardGroupMemberDomain> pojos);

}
